package com.musicstore.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.musicstore.biz.AlbumBiz;
import com.musicstore.biz.GenreBiz;
import com.musicstore.biz.OrderdetailBiz;
import com.musicstore.biz.ShoppingCartBiz;
import com.musicstore.entity.AlbumEntity;
import com.musicstore.entity.GenreEntity;
@Controller
public class OrderDetailController {
	@Autowired
	private OrderdetailBiz orderDetailBiz;
	@Autowired
	private AlbumBiz albumBiz;
	@Autowired
	private GenreBiz genreBiz;
	@RequestMapping("/orderdetaillist")
	public String orderdetaillist(Model model,String title,Integer pageNo){
		pageNo=(pageNo==null)?1:pageNo;
  		int pageSize =5;
		int startIndex = (pageNo-1)*pageSize;
		List<AlbumEntity> albumlist = albumBiz.getAlbumTitle(title, startIndex, pageSize);
		model.addAttribute("albumlist",albumlist);
		List<GenreEntity> genrelist = genreBiz.getAll();
		model.addAttribute("genrelist",genrelist);
		model.addAttribute("orderdetails",orderDetailBiz.query());
		return "shopping";
	}
}
